{template 'web/common/common'}
{template 'webapp/webappSet/navbar'}

<link rel="stylesheet" type="text/css" href="../addons/kundian_farm/resource/css/layui.css" />
<link rel="stylesheet" type="text/css" href="../addons/{php echo $_GPC['m']}/resource/swal/dist/sweetalert2.min.css" />
<style>
    body{background: white;}
    .layui-timeline-item:before, hr{background: white}
</style>
<blockquote class="layui-elem-quote layui-text">
    轮播图列表
</blockquote>
<div class="layui-card">
    <div class="layui-card-body">
        <a href="{url 'site/entry/webapp',array('m'=>'kundian_farm','op'=>'slide_set_edit','version_id'=>$_GPC['version_id'])}">
            <button type="button" class="layui-btn">添加</button>
        </a>
    </div>
</div>
<div class="layui-form">
    <form action="">
    <table class="layui-table">
        <colgroup>
            <col width="150">
            <col width="150">
            <col width="200">
            <col>
        </colgroup>
        <thead>
        <tr>
            <th>图片</th>
            <th>是否显示</th>
            <th>排序</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        {loop $list $key $item}
        <tr>
            <td><img src="{$item['slide_src']}" style="width: 95px;height: 45px;" alt=""></td>
            <td>
                {if $item['status']==1}
                是
                {else}
                否
                {/if}
            <td>{$item['rank']}</td>
            <td>
                <a href="{url 'site/entry/webapp',array('m'=>'kundian_farm','id'=>$item['id'],'op'=>'slide_set_edit','version_id'=>$_GPC['version_id'])}">
                    <button type="button" class="layui-btn layui-btn-sm"><i class="layui-icon"></i></button>
                </a>
                <button type="button" class="layui-btn layui-btn-sm delete" data-id="{$item['id']}"><i class="layui-icon"></i></button>
            </td>
        </tr>
        {/loop}
        </tbody>
    </table>
    </form>
</div>
<script src="../addons/kundian_farm/resource/layui.js" charset="utf-8"></script>
<script src="../addons/kundian_farm/resource/layui.all.js" charset="utf-8"></script>
<script src="../addons/kundian_farm/resource/lay/modules/form.js" charset="utf-8"></script>
<script>
    require(["../addons/{php echo $_GPC['m']}/resource/swal/dist/sweetalert2.min.js"],function(){
        $(function(){
            //实现全选以及反选
            $("#checkAll").on('click',function() {
                console.log("dsds");
                $("input[name='slideid[]']").prop("checked", this.checked);
            });
            //删除
            $(".delete").click(function(){
                console.log("dsds");
                var that=$(this);
                var id=$(this).attr('data-id');
                swal({
                    title: '提示',
                    text: "确定删除吗?",
                    type: 'warning',
                    showCancelButton: true,
                    confirmButtonColor: '#3085d6',
                    cancelButtonColor: '#d33',
                    confirmButtonText: '删除',
                    cancelButtonText: '取消',
                }).then(function(isConfirm) {
                    if (isConfirm) {
                        $.ajax({
                            type:"post",
                            url:"{url 'site/entry/'.$_GPC['do'],array('m'=>$_GPC['m'],'op'=>'slide_delete','version_id'=>$_GPC['version_id'])}",
                            data:{id:id},
                            dataType:'json',
                            success:function(res){
                                if(res.status==1){
                                    swal('操作成功!', '操作成功!', 'success');
                                    that.parent().parent().remove();
                                }else{
                                    swal('操作失败!', '操作失败!', 'error');
                                }
                            }
                        })
                    }
                })
            });
        })
    })
</script>